/**
 * [80] 删除有序数组中的重复项 II
 *
 * @format
 * @lc app=leetcode.cn id=80 lang=javascript
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
    nums.delete = function (index) {
        for (let i = index; i < this.length - 1; i++) this[i] = this[i + 1]
        this.pop()
    }
    let count = 1
    let num = nums[0]
    for (let i = 1; i < nums.length; i++) {
        if (nums[i] === num) count++
        else {
            num = nums[i]
            count = 1
        }
        if (count > 2) nums.delete(i)
    }
    return nums.length
}
debugger
const nums = [0, 0, 1, 1, 1, 1, 2, 3, 3]
console.log(removeDuplicates(nums))
console.log(nums)
// @lc code=end
